package com.weishi.project.dataview.controller;

import cn.hutool.json.JSONObject;
import com.weishi.framework.web.domain.AjaxResult;
import com.weishi.project.dataview.service.IDataViewService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 数据大屏-训练数据模块
 */
@RestController
@RequestMapping("/dataview")
@Api(value = "TrainingData", description = "训练数据")
public class DataViewController {

    @Autowired
    private IDataViewService dataViewService;

    /**
     * 所选队伍人员数据
     */
    @GetMapping("/train")
    public AjaxResult getTrain() {
        int teamId = 1;

        Map<String, Object> ret = new HashMap<>();

        // 所选队伍人员数据
        Map<String, Object> teamPeople = dataViewService.getTeamPeopleTotal(teamId);

        // 所选队伍状态
        Map<String, Object> teamStatus = dataViewService.getTeamPeopleStatus(teamId);

        // 所选队伍受伤状态
        Map<String, Object> teamInjuredStatus = dataViewService.getTeamInjuredStatus(teamId);

        //竞赛目标列表
        List<Map<String, Object>> competitionTargetList = dataViewService.getCompetitionTarget(teamId);

        //所选队伍 年度目标完成时间
        List<Map<String, Object>> trainingTimeList = dataViewService.getTrainingTimeList(teamId);

        //所选队伍 年度目标完成度
        List<Map<String, Object>> teamAnnualPlanList = dataViewService.getTrainingPlanList(teamId);

        //专项训练前三名
        List<Map<String, Object>> tableData = dataViewService.getTrainingAchievementTop3(teamId);

        // 所选队伍水上专项训练总量图表数据(水上专项训练、路上专项训练的四个周期值)
        Map<String, Object> specialTrainingTotal = dataViewService.getSpecialTrainingTotal(teamId);

        // 所选队伍陆上专项训练各个艇种年度总数据[1x,2x,2-,4+,4-,8+]
        Map<String, Object> landBoatData = dataViewService.getLandBoatData(teamId);

        ret.put("teamPeople", teamPeople);
        ret.put("teamStatus", teamStatus);
        ret.put("teamInjuredStatus", teamInjuredStatus);
        ret.put("competitionTargetList", competitionTargetList);
        ret.put("trainingTimeList", trainingTimeList);
        ret.put("teamAnnualPlanList", teamAnnualPlanList);
        ret.put("tableData", tableData);
        ret.put("specialTrainingTotal", specialTrainingTotal);
        ret.put("landBoatData", landBoatData);
        return AjaxResult.success(ret);
    }

    /**
     * 队伍风采
     */
    @GetMapping("/teamInfo")
    public AjaxResult getTeamInfo() {
        int teamId = 1;
        Map<String, Object> ret = dataViewService.getTeamInfo(teamId);
        return AjaxResult.success(ret);
    }

    /**
     * 队伍列表
     */
    @GetMapping("/teamList")
    public AjaxResult getTeamList() {
        Map<String, Object> ret = new HashMap<>();

        List<Map<String, Object>> teamList = new ArrayList<>();
        Map<String, Object> temp = new HashMap<>();
        temp.put("id", 1);
        temp.put("teamName", "赛艇队");
        temp.put("field", "'紫蓬山'");
        Map<String, Object> temp2 = new HashMap<>();
        temp2.put("id", 1);
        temp2.put("teamName", "赛艇队");
        temp2.put("field", "'紫蓬山'");
        Map<String, Object> temp3 = new HashMap<>();
        temp3.put("id", 1);
        temp3.put("teamName", "赛艇队");
        temp3.put("field", "'紫蓬山'");
        Map<String, Object> temp4 = new HashMap<>();
        temp2.put("id", 1);
        temp4.put("teamName", "赛艇队");
        temp4.put("field", "'紫蓬山'");
        Map<String, Object> temp5 = new HashMap<>();
        temp2.put("id", 1);
        temp5.put("teamName", "赛艇队");
        temp5.put("field", "'紫蓬山'");

        teamList.add(temp);
        teamList.add(temp2);
        teamList.add(temp3);
        teamList.add(temp4);
        teamList.add(temp5);
        ret.put("teamList", teamList);
        return AjaxResult.success(ret);
    }

    @GetMapping("/weather")
    public AjaxResult getWeather() {
        int teamId = 1;
        JSONObject jsonObject = dataViewService.getWeather(teamId);
        return AjaxResult.success(jsonObject);
    }
}
